package fr.inserm.umr915.vcfserver.bio.ucsc.wgrna;

import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

import com.sleepycat.bind.tuple.TupleBinding;


import fr.inserm.umr915.vcfserver.bio.Segment;
import fr.inserm.umr915.vcfserver.bio.berkeley.DatabaseManager;
import fr.inserm.umr915.vcfserver.xml.XmlStreamSerializer;


public class WgRnaHandler extends DatabaseManager<WgRna>
	{
	private WgRna.Binding dataBinding=new WgRna.Binding();
	private WgRna.StaxSerializer stax=new WgRna.StaxSerializer();
	
	public WgRnaHandler()
		{

		}
	
	@Override
	public TupleBinding< WgRna> getDataBinding()
		{
		return this.dataBinding;
		}
	
	@Override
	public XmlStreamSerializer<WgRna> getXmlStreamSerializer()
		{
		return stax;
		}
	
	@Override
	protected Set<String> getNames(WgRna o) {
		Set<String> set=new HashSet<String>();
		set.add(o.getName());
		return set;
		}
	
	@Override
	public WgRna parse(String line) throws IOException
		{
		WgRna g= WgRna.parse(getDelim().split(line));
		if(!acceptChromosome(g.getChrom())) return null;
		return g;
		}
	@Override
	public Segment getSegment(WgRna o) {
		return new Segment(o.getChrom(),o.getChromStart(),o.getChromEnd());
		}
	}
